<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const p1 = new Promise((reslove, reject) => {
        setTimeout(() => {
          reslove(1);
        }, 2000);
      });

      const p2 = new Promise((reslove, reject) => {
        setTimeout(() => {
          reslove(2);
        }, 1000);
      });

      const p3 = new Promise((reslove, reject) => {
        setTimeout(() => {
          reject(new Error("..."));
          // reslove(3);
        }, 3000);
      });

      async function fn() {
        try {
          const data = await Promise.all([p1, p2, p3]);
          console.log(data);
        } catch (error) {
          console.log(error);
        }
        // Promise.all([p1, p2, p3])
        //   .then((data) => {
        //     console.log(data);
        //   })
        //   .catch((error) => {
        //     console.log(error);
        //   });
      }
      fn();
    </script>
  </body>
</html>
